from ultralytics import SAM
from PIL import Image
import cv2


# Load a model
model = SAM("sam2_b.pt")

# Display model information (optional)
model.info()

# imgPath = "resource/cars.jpg"
imgPath = "resource/people.jpg"

# from PIL
im1 = Image.open(imgPath)

# # Segment with bounding box prompt
results = model(im1, bboxes=[100, 100, 200, 200], save=True)

# # Segment with point prompt
# results = model(im1, points=[150, 150], labels=[1], save=True)

# Run inference with bboxes prompt
# results = model("path/to/image.jpg", bboxes=[100, 100, 200, 200])
#
# # Run inference with single point
# results = model(points=[900, 370], labels=[1])
#
# # Run inference with multiple points
# results = model(points=[[400, 370], [900, 370]], labels=[1, 1])
#
# # Run inference with multiple points prompt per object
# results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 1]])
#
# # Run inference with negative points prompt
# results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 0]])
